var JaikoolService = new (function() {
	this.init = function() {
		var observer = Components.classes["@mozilla.org/observer-service;1"]
				.getService(Components.interfaces.nsIObserverService);
		observer.addObserver(this, "jaikool-prefs-changed", false);
		jaikuapi.loadPrefs();
		this.sidebarBrowser = document.getElementById("sidebar");
	}
	this.shutdown = function() {
		var observer = Components.classes["@mozilla.org/observer-service;1"]
				.getService(Components.interfaces.nsIObserverService);
		observer.removeObserver(this, "jaikool-prefs-changed");
	}
	// for nsISupports
	this.QueryInterface = function(aIID) {
		// add any other interfaces you support here
		if (!aIID.equals(Components.interfaces.nsISupports)
				&& !aIID.equals(Components.interfaces.nsIObserver))
			throw Components.results.NS_ERROR_NO_INTERFACE;
		return this;
	}
	// for nsIObserver
	//
	this.observe = function(subject, topic, data) {
		switch (topic) {
			case "jaikool-prefs-changed" :
				jaikuapi.loadPrefs();
				break;
		}
	}
})();
window.addEventListener("load", function(e) {
	JaikoolService.init();
}, false);
window.addEventListener("unload", function(e) {
	JaikoolService.shutdown();
	jk_logger.debug("shutting down...");
}, false);